#include <stdio.h>

int main(int argc, char **argv)
{
	int num;
	int arr[100000] = {0};

	int no;
	int grade;

	int i = 0;
	int max = 0;

	scanf("%d", &num);

	while(num--)
	{
		scanf("%d %d", &no, &grade);
		arr[no] += grade;
	}

	for(i = 0; i < 100000; i++)
	{
		if(arr[i] > arr[max])
			max = i;
	}

	printf("%d %d\n", max, arr[max]);
	return 0;
}